<template>
  <div class="body">
    <!-- 标题 -->
    <v-food></v-food>
    <!-- 导航栏 -->
    <!-- 高级检索 -->
    <Row class="restand">
        <i-col class="standkepu" span="17">
          <div class="standardt">
            食品标准
          </div>
        </i-col>
    </Row>
    <Row class="restand">
        <i-col class="foodtree" span="5">
            <Tree :data="treedata" @on-select-change="getnode"></Tree>
        </i-col>
        <i-col class="foodresult" span="19">
            <div class="result">
              <div class="resultitem" v-for="(item,index) in results" :key="index">
                <div class="itemtitle" @click="getDetail(item.TS_NO)">{{ item.TS_NO }}&#12288;&#12288;{{ item.TS_NAME }}
                  <Tag checkable color="success" class="stalstatus" v-if="item.TS_VALIDITY==='现行'">{{item.TS_VALIDITY}}</Tag>
                  <Tag checkable color="error" class="stalstatus" v-else-if="item.TS_VALIDITY==='废止'">{{item.TS_VALIDITY}}</Tag>
                  <Tag checkable color="warning" class="stalstatus" v-else-if="item.TS_VALIDITY==='将实施'">{{item.TS_VALIDITY}}</Tag>
                </div>
                <div class="itemdetail">发布单位&#12288;&#12288;{{ item.TS_PUBLISH_DEPT }}</div>
                <div class="itemdetail">浏览次数&#12288;&#12288;{{ item.TS_VIEWS }}</div>
                <div class="itemtime"><Icon color="#428bca" size="20" type="ios-cloud-upload" /><span class="itemtimefabu">发布于&#8194;{{ item.TS_RELEASE_DATE }}</span><Icon color="#3c763d" size="20" type="md-checkbox" /><span class="itemtimeshishi">实施于&#8194;{{ item.TS_IMPLEMENT_DATE }}</span></div>
              </div>
             <Page :total="dataCount" :page-size="pageSize" show-total @on-change="changepage" v-if="showPage" class-name="changepage" show-elevator />
          </div>
        </i-col>
    </Row>
    <!-- 底部 -->
    <v-foot></v-foot>
    <Back-top></Back-top>
  </div>
</template>
<script>
import {neturl} from '../assets/js/common'
export default {
  name: 'seniorsearch',
  data () {
    return {
      msg: '内蒙古标准文献服务平台',
      theme1: 'light',
      byname: 'bymenu',
      value: '',
      results: [],
      modal1: false,
      modal2: false,
      modal3: false,
      keyword: '',
      dataCount: 0,
      pageSize: 10,
      pageNum: 1,
      showPage: false,
      islogin: false,
      islog: true,
      username: '',
      userinfo: '',
      cnname: '',
      scn: '',
      sen: '',
      sics: '',
      sccs: '',
      sisd: '',
      sefd: '',
      sstatus: '',
      button2: '',
      sfenlei: 'D',
      foodcode: '',
      ssnum: '',
      sdfu: '',
      ics: [],
      ccs: [],
      orgn: [],
      org: '',
      sorgnum: '',
      icsarry: [],
      ccsarry: [],
      orgarry: [],
      agenumber: '',
      treedata: [
        {
          title: '所有产品',
          expand: true,
          children: [
            {
              title: '食用农产品',
              value: 'C32',
              expand: true,
              children: [
                {
                  title: '鲜蛋',
                  value: 'C3201',
                  expand: false,
                  children: [
                    {
                      title: '家禽蛋',
                      value: 'C320101',
                      expand: false,
                      children: [
                        {
                          title: '鸡蛋',
                          value: 'C32010101'
                        },
                        {
                          title: '鸭蛋',
                          value: 'C32010102'
                        },
                        {
                          title: '鹌鹑蛋',
                          value: 'C32010103'
                        },
                        {
                          title: '鹅蛋',
                          value: 'C32010104'
                        }
                      ]
                    }
                  ]
                },
                {
                  title: '水产品',
                  value: 'C3202',
                  expand: false,
                  children: [
                    {
                      title: '贝类',
                      value: 'C320201',
                      expand: false,
                      children: [
                        {
                          title: '螺',
                          value: 'C32020101'
                        },
                        {
                          title: '蚌',
                          value: 'C32020102'
                        },
                        {
                          title: '蚬',
                          value: 'C32020103'
                        },
                        {
                          title: '蛤',
                          value: 'C32020104'
                        },
                        {
                          title: '蛏',
                          value: 'C32020105'
                        },
                        {
                          title: '蚶',
                          value: 'C32020106'
                        },
                        {
                          title: '贻贝',
                          value: 'C32020107'
                        },
                        {
                          title: '扇贝',
                          value: 'C32020108'
                        },
                        {
                          title: '鲍鱼',
                          value: 'C32020109'
                        },
                        {
                          title: '牡蛎',
                          value: 'C32020110'
                        }
                      ]
                    },
                    {
                      title: '藻类',
                      value: 'C320202',
                      expand: false,
                      children: [
                        {
                          title: '海苔',
                          value: 'C32020201'
                        },
                        {
                          title: '海带',
                          value: 'C32020202'
                        },
                        {
                          title: '龙须菜',
                          value: 'C32020205'
                        }
                      ]
                    },
                    {
                      title: '龟鳖类',
                      value: 'C320203',
                      expand: false,
                      children: [
                        {
                          title: '龟',
                          value: 'C32020301'
                        },
                        {
                          title: '鳖',
                          value: 'C32020302'
                        }
                      ]
                    },
                    {
                      title: '两栖类',
                      value: 'C320204',
                      expand: false,
                      children: [
                        {
                          title: '蛙',
                          value: 'C32020401'
                        }
                      ]
                    },
                    {
                      title: '淡水鱼虾蟹',
                      value: 'C320205',
                      expand: false,
                      children: [
                        {
                          title: '蟹',
                          value: 'C32020501'
                        },
                        {
                          title: '螯虾',
                          value: 'C32020502'
                        },
                        {
                          title: '沼虾',
                          value: 'C32020503'
                        },
                        {
                          title: '鲢鱼',
                          value: 'C32020504'
                        },
                        {
                          title: '鳙鱼',
                          value: 'C32020505'
                        },
                        {
                          title: '鲮鱼',
                          value: 'C32020506'
                        },
                        {
                          title: '鲤鱼',
                          value: 'C32020507'
                        },
                        {
                          title: '鲫鱼',
                          value: 'C32020508'
                        },
                        {
                          title: '鲥鱼',
                          value: 'C32020509'
                        },
                        {
                          title: '鲴鱼',
                          value: 'C32020510'
                        },
                        {
                          title: '鲂鱼',
                          value: 'C32020511'
                        },
                        {
                          title: '鳊鱼',
                          value: 'C32020512'
                        },
                        {
                          title: '鳢鱼',
                          value: 'C32020513'
                        },
                        {
                          title: '鮰鱼',
                          value: 'C32020514'
                        },
                        {
                          title: '鲃鱼',
                          value: 'C32020515'
                        },
                        {
                          title: '鳟鱼',
                          value: 'C32020516'
                        },
                        {
                          title: '鲑鱼',
                          value: 'C32020517'
                        },
                        {
                          title: '鮡鱼',
                          value: 'C32020518'
                        },
                        {
                          title: '鲈鱼',
                          value: 'C32020519'
                        },
                        {
                          title: '鲟鱼',
                          value: 'C32020520'
                        },
                        {
                          title: '肺鱼',
                          value: 'C32020521'
                        },
                        {
                          title: '梭鲈',
                          value: 'C32020522'
                        },
                        {
                          title: '鲶鱼',
                          value: 'C32020523'
                        },
                        {
                          title: '鲳鱼',
                          value: 'C32020524'
                        },
                        {
                          title: '草鱼',
                          value: 'C32020525'
                        },
                        {
                          title: '青鱼',
                          value: 'C32020526'
                        },
                        {
                          title: '鳍鱼',
                          value: 'C32020527'
                        },
                        {
                          title: '红鲌',
                          value: 'C32020528'
                        },
                        {
                          title: '丁鱥',
                          value: 'C32020529'
                        },
                        {
                          title: '黑鲈',
                          value: 'C32020530'
                        },
                        {
                          title: '塘鳢',
                          value: 'C32020531'
                        },
                        {
                          title: '黄鳝',
                          value: 'C32020532'
                        },
                        {
                          title: '泥鳅',
                          value: 'C32020533'
                        },
                        {
                          title: '狗鱼',
                          value: 'C32020534'
                        },
                        {
                          title: '银鱼',
                          value: 'C32020535'
                        },
                        {
                          title: '长嘴鱼',
                          value: 'C32020536'
                        },
                        {
                          title: '罗非鱼',
                          value: 'C32020537'
                        },
                        {
                          title: '拉氏鱥',
                          value: 'C32020538'
                        },
                        {
                          title: '雅罗鱼',
                          value: 'C32020539'
                        },
                        {
                          title: '条纹鲈',
                          value: 'C32020540'
                        },
                        {
                          title: '胭脂鱼',
                          value: 'C32020541'
                        },
                        {
                          title: '厚唇鱼',
                          value: 'C32020542'
                        },
                        {
                          title: '马口鱼',
                          value: 'C32020543'
                        },
                        {
                          title: '太阳鱼',
                          value: 'C32020544'
                        },
                        {
                          title: '黄颡鱼',
                          value: 'C32020545'
                        },
                        {
                          title: '细鳞鱼',
                          value: 'C32020546'
                        },
                        {
                          title: '高体革鯻',
                          value: 'C32020547'
                        },
                        {
                          title: '短盖巨脂鲤蛙',
                          value: 'C32020548'
                        },
                        {
                          title: '池沼公鱼',
                          value: 'C32020549'
                        },
                        {
                          title: '大泷六线鱼',
                          value: 'C32020550'
                        },
                        {
                          title: '金龙鱼',
                          value: 'C32020551'
                        },
                        {
                          title: '暗纹东方鲀',
                          value: 'C32020552'
                        },
                        {
                          title: '东江鱼',
                          value: 'C32020554'
                        },
                        {
                          title: '鳜',
                          value: 'C32020555'
                        },
                        {
                          title: '娃娃鱼',
                          value: 'C32020556'
                        },
                        {
                          title: '五强溪鱼',
                          value: 'C32020557'
                        }
                      ]
                    },
                    {
                      title: '海水鱼虾蟹',
                      value: '',
                      expand: false,
                      children: [
                        {
                          title: '蛙',
                          value: 'C32020401'
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              title: '粮食及粮食加工品',
              value: 'C01',
              expand: true,
              children: []
            },
            {
              title: '食用油、油脂及其制品',
              value: 'C02',
              expand: true,
              children: []
            },
            {
              title: '调味品',
              value: 'C03',
              expand: true,
              children: []
            },
            {
              title: '方便食品',
              value: 'C07',
              expand: true,
              children: []
            },
            {
              title: '烘焙食品',
              value: 'C08',
              expand: true,
              children: []
            },
            {
              title: '糕点',
              value: 'C24',
              expand: true,
              children: []
            },
            {
              title: '罐头',
              value: 'C09',
              expand: true,
              children: []
            },
            {
              title: '冷冻饮品和甜品',
              value: 'C10',
              expand: true,
              children: []
            },
            {
              title: '速冻食品',
              value: 'C11',
              expand: true,
              children: []
            },
            {
              title: '薯类和膨化食品',
              value: 'C12',
              expand: true,
              children: []
            },
            {
              title: '糖果制品（含巧克力及制品）',
              value: 'C13',
              expand: true,
              children: []
            },
            {
              title: '茶叶及相关制品',
              value: 'C14',
              expand: true,
              children: []
            },
            {
              title: '酒类',
              value: 'C15',
              expand: true,
              children: []
            },
            {
              title: '蔬菜制品',
              value: 'C16',
              expand: true,
              children: []
            },
            {
              title: '水果制品',
              value: 'C17',
              expand: true,
              children: []
            },
            {
              title: '炒货食品及坚果制品',
              value: 'C18',
              expand: true,
              children: []
            },
            {
              title: '蛋制品',
              value: 'C19',
              expand: true,
              children: []
            },
            {
              title: '可可及焙烤咖啡产品',
              value: 'C20',
              expand: true,
              children: []
            },
            {
              title: '食糖及制品',
              value: 'C21',
              expand: true,
              children: []
            },
            {
              title: '水产制品',
              value: 'C22',
              expand: true,
              children: []
            },
            {
              title: '淀粉及淀粉制品',
              value: 'C23',
              expand: true,
              children: []
            },
            {
              title: '豆制品',
              value: 'C25',
              expand: true,
              children: []
            },
            {
              title: '蜂产品',
              value: 'C26',
              expand: true,
              children: []
            },
            {
              title: '保健食品',
              value: 'C27',
              expand: true,
              children: []
            },
            {
              title: '医学用途配方食品',
              value: 'C28',
              expand: true,
              children: []
            },
            {
              title: '婴幼儿配方食品',
              value: 'C29',
              expand: true,
              children: []
            },
            {
              title: '特殊膳食食品',
              value: 'C30',
              expand: true,
              children: []
            },
            {
              title: '餐饮食品',
              value: 'C31',
              expand: true,
              children: []
            },
            {
              title: '食品添加剂',
              value: 'C33',
              expand: true,
              children: []
            },
            {
              title: '花卉木本植物及草本植物',
              value: 'C35',
              expand: true,
              children: []
            },
            {
              title: '饲料',
              value: 'C36',
              expand: true,
              children: []
            },
            {
              title: '种子',
              value: 'C37',
              expand: true,
              children: []
            },
            {
              title: '食品原料',
              value: 'C38',
              expand: true,
              children: []
            },
            {
              title: '其他食品',
              value: 'C39',
              expand: true,
              children: []
            },
            {
              title: '其他产品',
              value: 'C40',
              expand: true,
              children: []
            },
            {
              title: '动植物疫病',
              value: 'C41',
              expand: true,
              children: []
            },
            {
              title: '化妆品',
              value: 'C42',
              expand: true,
              children: []
            },
            {
              title: '药典',
              value: 'C43',
              expand: true,
              children: []
            },
            {
              title: '兽药',
              value: 'C44',
              expand: true,
              children: []
            },
            {
              title: '书',
              value: 'C45',
              expand: true,
              children: []
            },
            {
              title: '地方标准',
              value: 'C46',
              expand: true,
              children: []
            },
            {
              title: '团体标准',
              value: 'C47',
              expand: true,
              children: []
            },
            {
              title: '食药补充检测方法',
              value: 'C48',
              expand: true,
              children: []
            },
            {
              title: '付费标准',
              value: 'C49',
              expand: true,
              children: []
            }
          ]
        }
      ]
    }
  },
  methods: {
    getdeafault () {
      this.$Spin.show()
      // let baurl = ''
      // var isPro = process.env.NODE_ENV === 'production'
      // if (isPro) {
      //   baurl = process.env.API_HOST
      // }
      // let url = baurl + '/fx/foodcodex?p=tsLibList&s=fmfd&act=doSearch&keyword=&queryId=&hj=&isCurrent=2&isCompulsive=2&pageNum=' + this.pageNum
      // this.$axios.get(url
      // ).then(res => {
      //   // console.log(res)
      //   this.$Spin.hide()
      //   this.results = res.data.data.datas
      //   this.showPage = true
      //   this.dataCount = parseInt(res.data.data.counts)
      // })
      // console.log(this.pagenum)
      let upload = { data: '{pagenum: ' + "'" + 1 + "'" + ',code:' + "'" + this.foodcode + "'" + '}' }
      // console.log(upload)
      this.$axios.post(neturl + '/by/food/getlist', upload
      ).then(res => {
        this.$Spin.hide()
        // console.log(res.data.data.result)
        this.results = res.data.data.result.data.datas
        this.dataCount = res.data.data.result.data.counts
        this.showPage = true
      })
      // let url = '/fx/foodcodex?p=tsLibList&s=fmfd&act=doSearch&keyword=&queryId=&hj=&isCurrent=2&isCompulsive=2&pageNum=' + this.pageNum
      // this.$axios.get(url
      // ).then(res => {
      //   // console.log(res)
      //   this.$Spin.hide()
      //   this.results = res.data.data.datas
      //   this.showPage = true
      //   this.dataCount = parseInt(res.data.data.counts)
      // })
    },
    getnode (data) {
      this.$Spin.show()
      let code = data[0].value
      this.foodcode = code
      // let url = '/fx/foodcodex?p=tsLibList&s=fmfd&act=doSearch&fcTypeCode=' + code + '&keyword=&queryId=&hj=&isCurrent=2&isCompulsive=2&pageNum=' + this.pageNum
      // this.$axios.get(url
      // ).then(res => {
      //   // console.log(res)
      //   this.$Spin.hide()
      //   this.results = res.data.data.datas
      //   this.showPage = true
      //   this.dataCount = parseInt(res.data.data.counts)
      // })
      let upload = { data: '{pagenum: ' + "'" + 1 + "'" + ',code:' + "'" + this.foodcode + "'" + '}' }
      // console.log(upload)
      this.$axios.post(neturl + '/by/food/getlist', upload
      ).then(res => {
        this.$Spin.hide()
        // console.log(res.data.data.result)
        this.results = res.data.data.result.data.datas
        this.dataCount = res.data.data.result.data.counts
        this.showPage = true
      })
    },
    getnodepage () {
      this.$Spin.show()
      let code = this.foodcode
      let url = '/fx/foodcodex?p=tsLibList&s=fmfd&act=doSearch&fcTypeCode=' + code + '&keyword=&queryId=&hj=&isCurrent=2&isCompulsive=2&pageNum=' + this.pageNum
      this.$axios.get(url
      ).then(res => {
        // console.log(res)
        this.$Spin.hide()
        this.results = res.data.data.datas
        this.showPage = true
        this.dataCount = parseInt(res.data.data.counts)
      })
    },
    changepage (value) {
      this.pageNum = value
      this.getnodepage()
    },
    getDetail (standnum) {
      // console.log(id)
      // let routeData = 'https://www.sdtdata.com/fx/fmfd/tsLibCard/' + id + '.html'
      // window.open(routeData, '_blank')
      let routeUrl = this.$router.resolve({path: '/seniorsearch', query: {keyword: standnum}})
      window.open(routeUrl.href, '_self')
    },
    logout () {
      this.$cookie.delete('user')
      let routeUrl = this.$router.resolve({
        path: '/'
      })
      window.open(routeUrl.href)
    }
  },
  created () {
    this.getdeafault()
    this.userinfo = this.$cookie.get('user')
    this.userinfo = JSON.parse(this.userinfo)
    // 已登录
    if (this.userinfo != null) {
      this.islogin = true
      this.islog = false
      this.username = this.userinfo.realName
    }
    this.keyword = this.$route.query.keyword
    if (this.keyword !== '' && this.keyword !== undefined) {
      this.getSearchResult()
    }
  }
}
</script>

<style scoped>
  @import '../assets/css/food.css';
</style>
